/****

    activequant - activestocks.eu

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

	
	contact  : contact@activestocks.eu
    homepage : http://www.activestocks.eu

 ****/
package org.activequant.core.domainmodel.options;

import java.io.Serializable;
import java.util.Map;

import org.activequant.core.domainmodel.InstrumentSpecification;
import org.activequant.core.domainmodel.data.Quote;

/**
 * This is a generic pricer. It requires any number of long options and short
 * options. <br/>
 * But all must be working with the same underlying and all must have the same
 * expiry. <br/>
 * An IOptionCombination implementation. Holds the following associated variables:
 * <ul>
 * <li>underlying(InstrumentSpecification)</li>
 * <li>longOptions(InstrumentSpecification[])</li>
 * <li>longQuantities(double[])</li>
 * <li>shortOptions(InstrumentSpecification[])</li>
 * <li>shortQuantities(double[])</li>
 * </ul>
 * <br>
 * <b>History:</b><br>
 * - [22.09.2007] Created (Ulrich Staudinger)<br>
 * - [22.09.2007] Switched to Map<..> and IllegalArgumentException (Erik
 * Nijkamp)<br>
 * 
 * @author Ulrich Staudinger
 */
public class GenericOptionCombinationPrizer implements IOptionCombination, Serializable {

	private static final long serialVersionUID = -7437919978008742735L;
	/**
	 * InstrumentSpecification underlying;
	 */
	InstrumentSpecification underlying;
	/**
	 * InstrumentSpecification[] longOptions, shortOptions;
	 */
	InstrumentSpecification[] longOptions, shortOptions;
	/**
	 * double[] longQuantities, shortQuantities;
	 */
	double[] longQuantities, shortQuantities;
	/**
	 * constructs a GenericOptionCombinationPrizer(IOptionCombination implementation) using the given underlying(InstrumentSpecification), longOptions(InstrumentSpecification[]) and
	 * shortOptions(InstrumentSpecification[]) to set its associated underlying(InstrumentSpecification), longOptions(InstrumentSpecification[]) and shortOptions(InstrumentSpecification[]).<br/>
	 * Sets its associated longQuantities(double[]) and shortQuantities(double[]) with double[] arrays with 1's
	 * @param underlying
	 * @param longOptions
	 * @param shortOptions
	 */
	public GenericOptionCombinationPrizer(InstrumentSpecification underlying, InstrumentSpecification[] longOptions, InstrumentSpecification[] shortOptions) {
		this.underlying = underlying;
		this.longOptions = longOptions;
		this.shortOptions = shortOptions;
		longQuantities = new double[longOptions.length];
		shortQuantities = new double[shortOptions.length];
		for (int i = 0; i < longQuantities.length; i++)
			longQuantities[i] = 1;
		for (int i = 0; i < shortQuantities.length; i++)
			shortQuantities[i] = 1;

	}
	/**
	 * constructs a GenericOptionCombinationPrizer(IOptionCombination implementation) using the given underlying(InstrumentSpecification), longOptions(InstrumentSpecification[]), longQuantities(double[]), 
	 * shortOptions(InstrumentSpecification[]) and shortQuantities(double[]) to set its associated underlying(InstrumentSpecification), longOptions(InstrumentSpecification[]), longQuantities(double[]), 
	 * shortOptions(InstrumentSpecification[]) and shortQuantities(double[]).
	 * @param underlying
	 * @param longOptions
	 * @param longQuantities
	 * @param shortOptions
	 * @param shortQuantities
	 */
	public GenericOptionCombinationPrizer(InstrumentSpecification underlying, InstrumentSpecification[] longOptions, double[] longQuantities, InstrumentSpecification[] shortOptions, double[] shortQuantities) {
		this.underlying = underlying;
		this.longOptions = longOptions;
		this.shortOptions = shortOptions;
		this.longQuantities = longQuantities;
		this.shortQuantities = shortQuantities;
	}

	public double cashFlowOpenPosition(Map<InstrumentSpecification, Quote> rateSheet) {
		// TODO.
		return 0;
	}

	public double cashFlowClosePosition(Map<InstrumentSpecification, Quote> rateSheet) {
		// TODO:
		return 0;
	}

	public double cashFlowAtExpiry(Map<InstrumentSpecification, Quote> rateSheet) {
		// TODO.
		return 0;
	}

}
